<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../base/taglibs.jsp"%>
<ssm:overwrite name="style">
	<link rel="stylesheet" href="${STATIC}/css/select2.css" />
</ssm:overwrite>
<ssm:overwrite name="context">
	<form class="form-horizontal" id="validation-form" action="edit" method="POST">
		<div class="widget-body">
			<div class="widget-main">
				<div class="step-content row-fluid position-relative">
						<h3 class="lighter block green">${WEB_TITLE}</h3>
						<div class="form-group">
							<label class="control-label col-xs-12 col-sm-3 no-padding-right">name:</label>
							<div class="col-xs-12 col-sm-9">
								<div class="clearfix">
									<input type="text" name="name" id="name" value="${action.name}"
										class="col-xs-12 col-sm-6" />
								</div>
							</div>
						</div>
						<div class="space-2"></div>
						<div class="form-group">
							<label class="control-label col-xs-12 col-sm-3 no-padding-right">title:</label>
							<div class="col-xs-12 col-sm-9">
								<div class="clearfix">
									<input type="text" name="title" value="${action.title}"
										class="col-xs-12 col-sm-4" />
								</div>
							</div>
						</div>
						<div class="space-2"></div>
						<div class="form-group">
							<label class="control-label col-xs-12 col-sm-3 no-padding-right">type:</label>

							<div class="col-xs-12 col-sm-9">
								<div class="clearfix">
									<input type="text" name="type" value="${action.type}"
										class="col-xs-12 col-sm-4" />
								</div>
							</div>
						</div>
						<div class="hr hr-dotted"></div>
						<div class="form-group">
							<label class="control-label col-xs-12 col-sm-3 no-padding-right"
								for="name">content:</label>

							<div class="col-xs-12 col-sm-9">
								<div class="clearfix">
									<input type="text" name="content" value="${action.content}"
										class="col-xs-12 col-sm-5" />
								</div>
							</div>
						</div>
						<div class="space-2"></div>
						<div class="form-group">
							<label class="control-label col-xs-12 col-sm-3 no-padding-right">rule:</label>
							<div class="col-xs-12 col-sm-9">
								<div class="clearfix">
									<textarea
										class="autosize-transition form-control col-xs-12 col-sm-8"
										name="rule">${action.rule}</textarea>
								</div>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-xs-12 col-sm-3 no-padding-right">logrule:</label>
							<div class="col-xs-12 col-sm-9">
								<div class="clearfix">
									<textarea
										class="autosize-transition form-control col-xs-12 col-sm-8"
										name="logrule">${action.logrule}</textarea>
								</div>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-xs-12 col-sm-3 no-padding-right"
								for="state">状态:</label>

							<div class="col-xs-12 col-sm-9">
								<select class="select2" name="status" selected="selected" value="${action.status}">
									<option value=-1 >删除</option>
									<option value=0 >停用</option>
									<option value=1 >启用</option>
								</select>
							</div>
						</div>
						<input type="hidden" name="id" value="${action.id}">
				</div>
				<div class="row-fluid wizard-actions">
					<button class="btn btn-success btn-next"  type="submit">
						提交<i class="icon-arrow-right icon-on-right"></i>
					</button>
				</div>

			</div>
			<!-- /widget-main -->
		</div>
		<!-- /widget-body -->
	</form>


</ssm:overwrite>
<ssm:overwrite name="script">
	<script src="${STATIC}/js/jquery.validate.min.js"></script>
	<script src="${STATIC}/js/jquery.maskedinput.min.js"></script>
	<script src="${STATIC}/js/jquery.autosize.min.js"></script>
	<!-- inline scripts related to this page -->
	<script type="text/javascript">
		jQuery(function($) {
			
			//textArea自动添加行数
			$('textarea[class*=autosize]').autosize({
				append : "\n"
			});
			
			//自动选中数据中的选项
			$('option[value="${action.status}"]').attr("selected","selected");
			


			$('#validation-form')
					.validate(
							{
								errorElement : 'div',
								errorClass : 'help-block',
								focusInvalid : false,
								rules : {
									name:{
									required : true
								},
									title : {
										required : true
									//minlength: 5
									},
									type : {
										required : false
									},
									content : {
										required : false
									},
									status : {
										required : true

									},
									createtime : {
										required : false
									},
									rule : {
										required : true
									},
									logrule : {
										required : false
									},
									id:{
										required:false
										}

								},

								messages : {
									title : {
										required : "title为必填."
									},
									name: {
										required: "name为必填",
									},
								},

								highlight : function(e) {
									$(e).closest('.form-group').removeClass(
											'has-info').addClass('has-error');
								},

								success : function(e) {
									$(e).closest('.form-group').removeClass(
											'has-error').addClass('has-info');
									$(e).remove();
								},

								errorPlacement : function(error, element) {
									if (element.is(':checkbox')
											|| element.is(':radio')) {
										var controls = element
												.closest('div[class*="col-"]');
										if (controls.find(':checkbox,:radio').length > 1)
											controls.append(error);
										else
											error.insertAfter(element.nextAll(
													'.lbl:eq(0)').eq(0));
									} else if (element.is('.select2')) {
										error
												.insertAfter(element
														.siblings('[class*="select2-container"]:eq(0)'));
									} else if (element.is('.chosen-select')) {
										error
												.insertAfter(element
														.siblings('[class*="chosen-container"]:eq(0)'));
									} else
										error.insertAfter(element.parent());
								},

								submitHandler : function(form) {
									form.submit(); 
								},
								invalidHandler : function(form) {
								}
							});
			

		})

	</script>
</ssm:overwrite>
<jsp:include page="../base/base.jsp"></jsp:include>